﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sharp.Infrastructure.Crosscutting
{
    public class FileSystemWatcherSingle
    {
        public FileSystemWatcher Wather;
        public readonly static FileSystemWatcherSingle Instance = new FileSystemWatcherSingle();


        public readonly Queue<LoggingHandler.UserLog> MyQueue = new Queue<LoggingHandler.UserLog>();
        private readonly string _watherFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log");
        private FileSystemWatcherSingle()
        {

            if (Wather == null)
            {
                Wather = new FileSystemWatcher();
                if (!Directory.Exists(_watherFolderPath))
                {
                    Directory.CreateDirectory(_watherFolderPath);
                }
                Wather.Path = _watherFolderPath;
                Wather.NotifyFilter = NotifyFilters.FileName |
                   NotifyFilters.LastWrite |
                   NotifyFilters.CreationTime;
                Wather.EnableRaisingEvents = true;
            }
        }


    }
}
